<template>
	<view class="container">
		<uni-section title="学员信息" type="line"></uni-section>
		<view class="query-form">
			<view class="query-item">学号 <view class="query-item-value">{{student.studentCode}}</view></view>
			<view class="query-item">姓名 <view class="query-item-value">{{student.studentName}}</view></view>
			<view class="query-item">手机号 <view class="query-item-value">{{student.phone}}</view></view>
			<view class="query-item">生日 <view class="query-item-value">{{parseTime(student.birthday, '{y}-{m}-{d}')}}</view></view>
			<view class="query-item">缴费 <view class="query-item-value">{{student.money}}</view></view>
			<view class="query-item">报名节数 <view class="query-item-value">{{student.classNum}}</view></view>
			<view class="query-item">剩余节数 <view class="query-item-value">{{getBalanceNum}}</view></view>
			<view class="query-item">备注 <view class="query-item-value">{{student.remark}}</view></view>
		</view>
		<uni-section :title="'体能指标:共 ' + total + ' 次'" type="line"></uni-section>
		<uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据">
			<uni-tr>
				<uni-th align="center">体能测试信息</uni-th>
				<uni-th align="center">备注</uni-th>
			</uni-tr>
			<uni-tr v-for="(item, index) in studentStrengthTestList" :key="index">
				<uni-td>
					<view class="name">日期: {{ parseTime(item.createTime, '{y}-{m}-{d}') }}</view>
					<view class="name">身高(cm): {{ item.height }}</view>
					<view class="name">体重(kg): {{ item.weight }}</view>
					<view class="name">摸高(cm): {{ item.touchHigh }}</view>
					<view class="name">立定cm: {{ item.standingLeap }}</view>
					<view class="name">一分钟跳绳n: {{ item.ropeSkipping }}</view>
					<view class="name">双打线折回跑5趟s: {{ item.doubleRunning }}</view>
				</uni-td>
				<uni-td>
					<view class="name remark">{{ item.remark }}</view>
				</uni-td>
			</uni-tr>
		</uni-table>
		<uni-pagination :page-size="queryParams.pageSize" :current="queryParams.pageNum" :total="total" @change="change"
			prev-text="前一页" next-text="后一页" />
		<view class="page-sum">
			<text>当前页：{{ queryParams.pageNum }}，数据总量：{{ total }} 条，每页数据：{{ queryParams.pageSize }} 条</text>
		</view>
	</view>
</template>

<script>	
	import { listStrengthTest, getStudent } from "@/api/puyu/student";
	import { parseTime } from '@/utils/common';
	import { getDicts } from "@/api/system/dict/data";
	export default {
		data() {
			return {
				// 遮罩层
				loading: true,
				// 总条数
				total: 0,
				// 学员信息
				student: {},
				// 学员课时点名表格数据
				studentStrengthTestList: [],
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
				},
			}
		},
		computed: {
			getBalanceNum() {
				let balanceNum = 0;
				if(this.student) {
					balanceNum = this.student.classNum - this.student.params.studentLessonCount;
				}
				return balanceNum;
			},
		},
		// created() {
		// 	this.getList();
		// },
		onLoad(option) {
			  const item = JSON.parse(decodeURIComponent(option.item));
			  this.student = item;
		},
		onShow() {
			this.getList();
		},
		methods: {
			parseTime,
			/** 查询课时点名列表 */
			getList() {
				this.loading = true;
				this.queryParams.studentId = this.student.studentId;
				listStrengthTest(this.queryParams).then(response => {
					this.studentStrengthTestList = response.rows;
					this.total = response.total;
					this.loading = false;
				});
			},
			// 分页触发
			change(e) {
				this.$refs.table.clearSelection()
				this.getData(e.current)
			},
			// 获取数据
			getData(pageCurrent, value = '') {
				this.queryParams.pageNum = pageCurrent
				this.getList()
			},
		}
	}
</script>

<style lang="scss" scoped>
	/* #ifndef H5 */
	/* page {
	padding-top: 85px;
} */
	/* #endif */

	.page-sum {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.query-form {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		background-color: #ffffff;
		margin-bottom: 10px;
	}

	.query-item {
		margin: 10rpx;
		padding: 5rpx;
	}
	
	.query-item-value {
		margin-top: 5rpx;
		color: darkgray;
	}
	.remark {
		color: #993399;
		font-weight: bolder;
	}
</style>